<template>
    <div class="goods-info">
        <div class="mui-card">
            <div class="mui-card-content">
                <div class="mui-card-content-inner">
                   <swiper :lunboList="goodslunbo"></swiper>
                </div>
            </div>
		</div>
        <!-- 商品购买区 -->
        <div class="mui-card">
			<div class="mui-card-header">页眉</div>
			<div class="mui-card-content">
				<div class="mui-card-content-inner">
						包含页眉页脚的卡片，页眉常用来显示面板标题，页脚用来显示额外信息或支持的操作（比如点赞、评论等）
				</div>
			</div>			
		</div>
        <!-- 商品参数区域 -->
        <div class="mui-card">
			<div class="mui-card-header">页眉</div>
			<div class="mui-card-content">
				<div class="mui-card-content-inner">
						包含页眉页脚的卡片，页眉常用来显示面板标题，页脚用来显示额外信息或支持的操作（比如点赞、评论等）
				</div>
			</div>
			<div class="mui-card-footer">页脚</div>
		</div>
    </div>
</template>
<script>
import {Toast} from 'mint-ui'
import common from '../../common/common.js'
import swiper from '@/components/subcomponents/Swiper'
    export default{
        data(){
            return{
                goodslunbo:{},
                goodsdesc:{},
                goodsinfo:{},
                id:this.$route.params.id,
            }
        },
        created(){
            this.getlunbo(),
            this.getGoodsDesc(),
            this.getGoodsInfo()
        },
        methods:{
            getlunbo(){
                this.$http.get('api/getthumimages/' + this.id).then(result=>{
                    if(result.body.status === 0){
                        
                        // this.goodsinfo = result.body.message
                        result.body.message.forEach(item => {
                            item.img=common.imghost + item.src
                        })
                        this.goodslunbo = result.body.message
                        console.log(this.goodslunbo)
                    }else{
                        Toast('商品图片获取失败')
                    }
                })
            },
            //商品详情 api/goods/getdesc/ 
            getGoodsDesc(){
                this.$http.get('api/goods/getdesc/' + this.id).then(result=>{
                    if(result.body.status === 0){
                        this.goodsdesc=result.body.message[0]
                         console.log(result.body)
                    }else{
                         Toast('商品详情获取失败')
                    }
                })
            },
            getGoodsInfo(){
                this.$http.get('api/goods/getinfo/' + this.id).then(result=>{
                    if(result.body.status === 0){
                        this.goodsinfo=result.body.message
                         console.log(result.body)
                    }else{
                         Toast('商品详情获取失败')
                    }
                })
            }
        },
        components:{
            swiper
        }

    }
</script>
<style lang="scss" scoped>
    .goods-info{
        background-color: #eee;
        overflow: hidden;
    }
</style>